/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.henryschein.mmvvcc.controller;

import com.henryschein.mmvvcc.dao.PersonDao;
import com.henryschein.mmvvcc.model.Person;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 *
 * @author Alexx
 */
@Controller
public class AjaxController {

    @Autowired
    private PersonDao personDao;

    @RequestMapping(value = "/data/content.html", method = RequestMethod.GET)
    public String home(Model model) {
            model.addAttribute("person", getQuote());    
        return "test";
    }

    private Person getQuote() {
        List<Person> list = personDao.getPeople();
        int randomPosition = (int) (list.size() * Math.random());
        return list.get(randomPosition);
    }
}
